﻿using System.Collections.Generic;
using LitJson;
using OestsCommon.Model;
using LNet;
using OestsDataBase;
using OestsServer.Net;

namespace OestsServer.Handlers.OESPHandlers
{
	public class AddTrueOrFalseHandler : HandlerBase<OESPClientChannel>
    {
		public override PacketKey PKey => PacketKey.AddTrueOrFalse;

		public override void Execute(OESPClientChannel client, Request resquestPacket)
		{
			List<TrueOrFalse> list = JsonMapper.ToObject<List<TrueOrFalse>>(resquestPacket.DataStr);
            if (list != null) { list.ForEach(s => s.Id = SubjectTrueOrFalseDAL.Add(s)); }
			ResponsePacket.DataObject = list;
			client.Send(ResponsePacket);
		}
	}
}
